home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / ada / adaed-1.11 / adaed-1 / Adaed-1.11.0a / makech < prev    next >
Encoding:
Text File  |  1992-02-07  |  1.7 KB  |  50 lines

  1.  
  2. # This is a shell script version of the program which transforms a .ch
  3. #  file into either a .h file or a .c file.  This is used to create
  4. #  matching .c and .h files from a common source (the .ch file) where
  5. #  the .c file contains variable definitions and the .h file contains
  6. #  corresponding external declarations.  The program is run twice
  7. #  on a .ch file: once with the "-c" option to create the .c file
  8. #  and once with the "-h" option to create the .h file (the program
  9. #  reads from standard input and writes to standard output - the
  10. #  extensions named here are just the conventional ones).
  11. #
  12. # In either case block comments (rather crudely defined - see the cdecom
  13. #  script which uses the same rules) are first stripped out by the first
  14. #  half of the pipeline (the first sed command). After the comments are
  15. #  stripped out the file is filtered according to:
  16. #    -c option:
  17. #        >lines starting with 'C' or 'X' are copied with 1st character removed
  18. #        >lines starting with 'H' are discarded
  19. #        >all other lines are copied out
  20. #    -h option:
  21. #        >lines starting with 'H' are copied with 1st character removed
  22. #        >lines starting with 'X' are copied with 'X' replaced by 'extern'
  23. #        >lines starting with 'C' are discarded
  24. #        >all other lines are copied out
  25.  
  26. if [ $# -ne 1 -o "$1" != '-c' -a  "$1" != '-h' ]
  27. then
  28.     echo "usage: makech -c|-h"
  29.     exit 1
  30. fi
  31.  
  32. sed -e '
  33.   /^[     ]*\/\*.*\*\// d
  34.   /^[     ]*\/\*/,/\*\// d' | \
  35. if [ $1 = '-c' ]
  36. then
  37.     echo '#define INIT(v) =v '
  38.     sed -e '
  39.       /^H/ d
  40.       s/^X/ /
  41.       s/^C//'
  42. elif [ $1 = -h ]
  43. then
  44.     echo '#define INIT(v) '
  45.     sed -e '
  46.       /^C/ d
  47.       s/^X/extern  /
  48.       s/^H//'
  49. fi
  50.